package com.controllers;

import com.entities.Person;
import com.DAOs.PersonsDAO;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


/**
 * @author Harit
 *
 */

@Controller
public class ContactsControllers
{
	@Autowired
	private PersonsDAO personsDAO;
	
	@RequestMapping("/home")
	public String home(){
            return "home";
	}
	
	
	@RequestMapping("/viewAllPersons")
	public ModelAndView getAllContacts()
	{
		ModelAndView mav = new ModelAndView("showPersons");
		List<Person> persons = personsDAO.getAllContacts();
		mav.addObject("SEARCH_PERSONS_RESULTS_KEY", persons);
		return mav;
	}
	
	
	
}
